package com.chengqs.config;

import com.chengqs.interceptor.LoginInterceptor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * 本来用来演示:
 *
 * @author success
 * @date 2024/11/5 14:32:17
 */
@Configuration
public class WebConfig implements WebMvcConfigurer {
    @Autowired
    private LoginInterceptor loginInterceptor;
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(loginInterceptor)
                .addPathPatterns("/**")//哪些路径需要拦截
                .excludePathPatterns(
                        "/users/sendCode",
                        "/users/login",
                        "/movies/**")
                .excludePathPatterns("/views/**","/plugins/**","/imgs/**");//哪些路径不需要拦截
    }
}
